import { reactive } from "vue";
import { getAllCompanyApi, getUserByPositionApi } from "@/api/managementCenter/departmentPersonnel";
// import { getListApi as getCustomerApi } from "@/api/managementCenter/customerManagement";
import { getAllCustomerApi } from "@/api/common";
export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "运单号",
    keyName: "waybillNums",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  // {
  //   type: "input",
  //   label: "客户简称",
  //   keyName: "shortName"
  // },
  // {
  //   type: "input",
  //   label: "客户名称",
  //   keyName: "customerName"
  // },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "客户简称",
    keyName: "customerIdList",
    optionsRequest: getAllCustomerApi,
    optReqParams: { isFilterChild: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "shortName",
      value: "id"
    },
    options: []
  }),
  {
    type: "input",
    label: "费用名称",
    keyName: "costName"
  },
  {
    type: "datetimerange",
    label: "追加时间",
    keyName: "createTime"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "追加人",
    keyName: "createByList",
    optionsRequest: getUserByPositionApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "username",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  }),
  {
    type: "datetimerange",
    label: "拣货时间",
    keyName: "depositTime"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "经营单位",
    keyName: "companyIdList",
    optionsRequest: getAllCompanyApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },

    options: []
  })
];

export const tableColumnMap: Base.GeneraDataType<Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>> = {
  "0": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50",
      fixed: "left"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "150"
    },
    {
      field: "shortName",
      title: "客户简称",
      minWidth: "120",
      sortable: true
    },
    {
      field: "customerName",
      title: "客户名称",
      minWidth: "120"
    },
    {
      field: "channelName",
      title: "预报渠道",
      minWidth: "140",
      sortable: true
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "70"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "70"
    },
    {
      field: "settlementWeight",
      title: "收费重",
      minWidth: "70"
    },
    {
      field: "costName",
      title: "费用名称",
      minWidth: "120"
    },
    {
      field: "totalPrice",
      title: "费用金额",
      minWidth: "90"
    },
    {
      field: "remark",
      title: "追加说明",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "100",
      sortable: true
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "100",
      sortable: true
    },
    {
      field: "finName",
      title: "财务代表",
      minWidth: "100"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "120",
      sortable: true
    },
    {
      field: "depositTime",
      title: "拣货时间",
      minWidth: "135",
      formatter: "formatDate",
      sortable: true
    },
    {
      field: "createOrderTime",
      title: "下单时间",
      minWidth: "135",
      formatter: "formatDate",
      sortable: true
    },
    {
      field: "createName",
      title: "追加人",
      minWidth: "80"
    },
    {
      field: "createTime",
      title: "追加时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "90",
      fixed: "right",
      renderSlot: "action"
    }
  ],
  "1": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50",
      fixed: "left"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "150"
    },
    {
      field: "shortName",
      title: "客户简称",
      minWidth: "120",
      sortable: true
    },
    {
      field: "customerName",
      title: "客户名称",
      minWidth: "120"
    },
    {
      field: "approvalUserName",
      title: "审批人",
      minWidth: "120"
    },
    {
      field: "channelName",
      title: "预报渠道",
      minWidth: "140",
      sortable: true
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "70"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "70"
    },
    {
      field: "settlementWeight",
      title: "收费重",
      minWidth: "70"
    },
    {
      field: "costName",
      title: "费用名称",
      minWidth: "120"
    },
    {
      field: "totalPrice",
      title: "费用金额",
      minWidth: "90"
    },
    {
      field: "remark",
      title: "追加说明",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "100",
      sortable: true
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "100",
      sortable: true
    },
    {
      field: "finName",
      title: "财务代表",
      minWidth: "100"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "120",
      sortable: true
    },
    {
      field: "depositTime",
      title: "拣货时间",
      minWidth: "135",
      formatter: "formatDate",
      sortable: true
    },
    {
      field: "createOrderTime",
      title: "下单时间",
      minWidth: "135",
      formatter: "formatDate",
      sortable: true
    },
    {
      field: "createName",
      title: "追加人",
      minWidth: "80"
    },
    {
      field: "createTime",
      title: "追加时间",
      minWidth: "135",
      formatter: "formatDate"
    }
  ]
};
// 统计
export const statisticsColumn: Array<{ field: string; label: string }> = [
  {
    label: "票数",
    field: "ticketNumber"
  },
  {
    label: "件数",
    field: "itemNumber"
  },
  {
    label: "费用金额合计",
    field: "costTotalPrice"
  }
];
